package com.mxf.code.cases.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.UUID;

@RestController
@RequestMapping("/order")
@Validated
public class OrderController {

    @Autowired
    public OrderServiceImpl orderService;

    @GetMapping("/start")
    public Boolean page( String productName) {
        Order1 order1 = new Order1();
        order1.setAmount(BigDecimal.valueOf(5000));
        order1.setProductName(productName);
        order1.setOrderId(UUID.randomUUID().toString().replace("-", "").toLowerCase());
        orderService.start(order1);
        return Boolean.TRUE;
    }
}